import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop21_商品品牌添加"
name = "苹果"
# 1.点击添加品牌按钮，品牌名称“苹果”。
firefox=openBrowser(url) #调用自定义函数打开网页,url的值是在testData文件中定义的
firefox.get(urlAdmin)
#调用自定义函数进行后台的登录
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"商品管理","商品品牌")
firefox.find_element_by_link_text("添加品牌").click()
firefox.find_element_by_id("brand_name").send_keys("苹果")

# 2.点击“保存品牌”按钮。保存成功
firefox.find_element_by_xpath("//button").click()

# 断言
# s = firefox.find_element_by_xpath("//table/tbody/tr[1]/td[1]").text
try:
    firefox.find_element_by_xpath('//td[contains(.,"%s")]'%name).is_displayed()
    writeLog("%s 测试成功"%testCase)
    getPhoto(firefox)
except:
    writeLog("%s 测试失败" % testCase)
firefox.quit()